package net.gd.domain;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import net.gd.utils.Constants;
import net.sf.json.JSONObject;

public class UdfInfo {
  private String udfId;
  private String udfName;
  private String langType;
  private String udfContent;
  private String createUser;
  private Date createDatetime;
  private Date updateDatetime;

  public JSONObject toJson() {
    SimpleDateFormat df = new SimpleDateFormat(Constants.DATETIME_FORMAT);
    Map<String, String> map = new HashMap<>();
    if (this.udfId != null) {
      map.put("udf_id", this.udfId);
    }
    if (this.udfName != null) {
      map.put("udf_name", this.udfName);
    }
    if (this.langType != null) {
      map.put("lang_type", this.langType);
    }
    if (this.udfContent != null) {
      map.put("udf_content", this.udfContent);
    }
    if (this.createUser != null) {
      map.put("create_user", this.createUser);
    }
    if (this.createDatetime != null) {
      map.put("create_datetime", df.format(this.createDatetime));
    }
    if (this.updateDatetime != null) {
      map.put("update_datetime", df.format(this.updateDatetime));
    }
    return JSONObject.fromObject(map);
  }

  public String getUdfId() {
    return udfId;
  }

  public void setUdfId(String udfId) {
    this.udfId = udfId;
  }

  public String getUdfName() {
    return udfName;
  }

  public void setUdfName(String udfName) {
    this.udfName = udfName;
  }

  public String getLangType() {
    return langType;
  }

  public void setLangType(String langType) {
    this.langType = langType;
  }

  public String getUdfContent() {
    return udfContent;
  }

  public void setUdfContent(String udfContent) {
    this.udfContent = udfContent;
  }

  public String getCreateUser() {
    return createUser;
  }

  public void setCreateUser(String createUser) {
    this.createUser = createUser;
  }

  public Date getCreateDatetime() {
    return createDatetime;
  }

  public void setCreateDatetime(Date createDatetime) {
    this.createDatetime = createDatetime;
  }

  public Date getUpdateDatetime() {
    return updateDatetime;
  }

  public void setUpdateDatetime(Date updateDatetime) {
    this.updateDatetime = updateDatetime;
  }

  @Override
  public String toString() {
    return "UdfInfo [udfId=" + udfId + ", udfName=" + udfName + ", langType=" + langType
        + ", udfContent=" + udfContent + ", createUser=" + createUser + ", createDatetime="
        + createDatetime + ", updateDatetime=" + updateDatetime + "]";
  }


}
